#include <core/synced_lamp_centroids.h>
#include <boost/thread/locks.hpp>

using boost::unique_lock;

// Vector size will be less than 50, so copying it is not so bad
// and it keeps us out of memory management troubles.
void SyncedLampCentroids::set_lamp_centroids(const vector<player_point_2d> &lamp_centroids) {
  unique_lock<mutex> lock(mutex_);
  lamp_centroids_ = lamp_centroids;
}

vector<player_point_2d> SyncedLampCentroids::lamp_centroids() {
  unique_lock<mutex> lock(mutex_);
  vector<player_point_2d> lamp_centroids_copy(lamp_centroids_);
  lamp_centroids_.clear();
  return lamp_centroids_copy;
}

